#ifndef BALL_H
#define BALL_H

#include <QGraphicsSceneMouseEvent>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QTimer>

enum Direction {
    UP,
    DOWN
};

class Ball : public QObject, public QGraphicsItem {
    Q_OBJECT

public:
    Ball( QGraphicsScene *scene, QObject *object = 0, QGraphicsItem *parent = 0 );

    int diameter();

protected:
    virtual void mousePressEvent( QGraphicsSceneMouseEvent *e );
    virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent *e );

    void paint( QPainter *painter,
                const QStyleOptionGraphicsItem *option,
                QWidget *widget );
    QRectF boundingRect() const;

private slots:
    void move();

private:
    void bounce();
    void smoothMove();

    static const int       m_diameter   = 50;
    static const int       m_step       = 1;
    static const int       m_interval   = 4;

    int             m_topLimit;
    int             m_bottomLimit;
    int             m_hgt;
    QTimer         *m_timer;
    Direction       m_direction;
    QGraphicsScene *m_scene;

    int                 m_v;
    static const double m_g = 9.8;
};

#endif // BALL_H
